class Header {
  constructor(dataIndex: string, title: string, key: any) {
    this.dataIndex = dataIndex;
    this.title = title;
    this.key = key;
  }

  protected _params: object = {};
  set params(params: object) {
    this._params = params ? params : {};
  }
  get params() {
    let params = {
      title: this.title,
      dataIndex: this.dataIndex,
      key: this.key,
      edit: this.edit,
      ellipsis: this.ellipsis
    };

    if (this.helpMessage) {
      params.helpMessage = this.helpMessage;
    }

    if (this.width) {
      params.width = this.width;
    }

    if (this.fixed) {
      params.fixed = this.fixed;
    }

    if (this.slots) {
      params.slots = this.slots;
    }

    return params;
  }

  protected _dataIndex: string = '';
  set dataIndex(dataIndex: string) {
    this._dataIndex = dataIndex;
  }
  get dataIndex() {
    return this._dataIndex;
  }

  protected _title: string = '';
  set title(title: string) {
    this._title = title;
  }
  get title() {
    return this._title;
  }

  protected _key: string = '';
  set key(key: string) {
    this._key = key;
  }
  get key() {
    return this._key;
  }

  protected _edit: boolean = false;
  set edit(edit: boolean) {
    this._edit = edit;
  }
  get edit() {
    return this._edit;
  }

  protected _ellipsis: boolean = true;
  set ellipsis(ellipsis: boolean) {
    this._ellipsis = ellipsis;
  }
  get ellipsis() {
    return this._ellipsis;
  }

  protected _width: number = 0;
  set width(width: number) {
    this._width = width;
  }
  get width() {
    return this._width;
  }

  protected _fixed: string = '';
  set fixed(fixed: string) {
    this._fixed = fixed;
  }
  get fixed() {
    return this._fixed;
  }

  protected _helpMessage: string = '';
  set helpMessage(helpMessage: string) {
    this._helpMessage = helpMessage;
  }
  get helpMessage() {
    return this._helpMessage;
  }

  protected _slots: object = {};
  set slots(slots: obejct) {
    this._slots = slots;
  }
  get slots() {
    return this._slots;
  }

  setImages() {
    this._slots.customRender = 'images';
    this._slots.imgList = [];
  }

  setSwitch() {
    this._slots.customRender = 'switch';
  }

  setAction(width: number = 100) {
    this._slots.customRender = 'action';
    this.width = width;
    this.fixed = 'right';
    this.ellipsis = false;
  }

  clear() {
    this._slots = {};
  }
}

export default Header;
